package com.qf.service.impl;

import com.qf.dao.StudentDao;
import com.qf.dao.impl.StudentDaoImpl;
import com.qf.pojo.Student;
import com.qf.service.StudentService;

import java.util.List;

/**
 * Created by 54110 on 2021/7/5.
 */
public class StudentServiceImpl implements StudentService {


    @Override
    public List<Student> findAll() {

       StudentDao studentDao = new StudentDaoImpl();

        return studentDao.findAll();
    }

    @Override
    public boolean insertStudent(Student student) {
        StudentDao studentDao = new StudentDaoImpl();
        Integer cell = studentDao.insertStudent(student);
        if (cell>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean deleteById(Integer id) {
        StudentDao studentDao = new StudentDaoImpl();
        Integer cell = studentDao.deleteById(id);
        if (cell>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Student findById(Integer id) {
        StudentDao studentDao = new StudentDaoImpl();
        Student student = studentDao.findById(id);
        return student;
    }

    @Override
    public boolean updateStudent(Student student) {
        StudentDao studentDao = new StudentDaoImpl();
        Integer cell = studentDao.updateById(student);
        if (cell>0){
            return true;
        }else {
            return false;
        }
    }
}
